using UnityEngine;
using QFramework;
using System.Collections.Generic;
using ProjectSurvivor;

namespace QFrameworkSurvivor
{
    public partial class BasketBallAbility : ViewController
    {
        
        private List<Ball> mBalls = new List<Ball>();
        void Start()
        {
            void CreateBall()
            {
                mBalls.Add(Ball.Instantiate()
                              .SyncPosition2DFrom(this)
                              .Show());
            }
            void CreatBalls()
            {
                var ballcount2Create = Global.BasketBallCount.Value + Global.AdditionalFlyThingCount.Value - mBalls.Count;
                //count += Global.AdditionalFlyThingCount.Value;
                for (int i = 0; i < ballcount2Create; i++)
                {
                    CreateBall();
                }
            }
            Global.BasketBallCount.Or(Global.AdditionalFlyThingCount).Register(() => 
            {
                CreatBalls();
            }).UnRegisterWhenGameObjectDestroyed(gameObject);
            CreatBalls();
        }
    }
}
